<template>
  <div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>基本信息</h4>
        <el-form label-width="180px">
          <el-row>
            <el-form-item label="所属分公司">
              <span>{{this.detailData.branchName}}</span>
            </el-form-item>
            <el-form-item label="所属部门">
              <span>{{this.detailData.departName}}</span>
            </el-form-item>
            <el-form-item label="客资类型">
              <span>{{this.detailData.customerName}}</span>
            </el-form-item>
            <el-form-item label="促销费用">
              <span>{{this.detailData.cxName}}</span>
            </el-form-item>
            <el-form-item v-if="this.detailData.providerRatio !== 0" label="供应商占比">
              <span>{{this.detailData.providerRatio}}</span>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>批次信息</h4>
        <el-form label-width="180px">
          <el-form-item label="批次名称">
            <span>{{this.detailData.batchName}}</span>
          </el-form-item>
          <el-form-item label="活动时间">
            <span>{{this.detailData.activityYm}}</span>
          </el-form-item>
          <el-form-item label="订单满足金额">
            <span>{{this.detailData.orderFullMoney}}</span>
          </el-form-item>
          <el-form-item label="第0单可领">
            <span v-if="this.detailData.zeroCan === 1">是</span>
            <span v-if="this.detailData.zeroCan === 0">否</span>
          </el-form-item>
          <el-form-item label="最后笔订单重复">
            <span v-if="this.detailData.loopLastOrder === 1">是</span>
            <span v-if="this.detailData.loopLastOrder === 0">否</span>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>优惠券信息</h4>
        <el-table :data="this.detailData.tickets" border>
          <el-table-column prop="orderNum" label="订单" align="center" width="90"></el-table-column>
          <el-table-column prop="ticketId" label="优惠券ID" align="center" width="90"></el-table-column>
          <el-table-column prop="ticketName" label="优惠券名称" align="center" width="100"></el-table-column>
          <el-table-column label="优惠券类型" align="center" width="100">
            <template scope="scope">
              <span v-if="scope.row.ticketType === 1">现金券</span>
              <span v-if="scope.row.ticketType === 2">满减券</span>
              <span v-if="scope.row.ticketType === 3">实物券</span>
              <span v-if="scope.row.ticketType === 4">品牌现金券</span>
            </template>
          </el-table-column>
          <el-table-column prop="ticketMoney" label="面值" align="center" width="50"></el-table-column>
          <el-table-column prop="fullUse" label="满多少元可用" align="center" width="100"></el-table-column>
          <el-table-column prop="numLimit" label="满多少件可用" align="center"></el-table-column>
          <el-table-column prop="expiryDateType" label="有效期类型" align="center" width="100">
            <template scope="scope" >
              <span v-if="scope.row.expiryDateType===1">时间段</span>
              <span v-if="scope.row.expiryDateType===2">截止时间</span>
              <span v-if="scope.row.expiryDateType===3">天数</span>
            </template>
          </el-table-column>
          <el-table-column label="有效期" align="center">
            <template scope="scope">
              <span v-if="scope.row.expiryDateType===1">{{timeDeltSecond(scope.row.startTime)}}-{{timeDeltSecond(scope.row.endTime)}}</span>
              <span v-if="scope.row.expiryDateType===2">{{timeDeltSecond(scope.row.endTime)}}</span>
              <span v-if="scope.row.expiryDateType===3">{{scope.row.days}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ticketTimes" label="每人/张数" align="center" width="100"></el-table-column>
          <el-table-column prop="ticketUser" label="建券人" align="center" width="70"></el-table-column>
          <!-- <el-table-column prop="historyTotal" label="累计已发放张数" align="center" width="100"></el-table-column>
          <el-table-column prop="todayTotal" label="今日已发放张数" align="center" width="100"></el-table-column> -->
        </el-table>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px;margin-bottom:80px">
      <div class="form-item">
        <h4>审核信息</h4>
        <el-table :data="this.detailData.checkInfo" border>
          <el-table-column prop="auditor" label="审核人名称" align="center"></el-table-column>
          <el-table-column prop="content" label="任务内容" align="center"></el-table-column>
          <el-table-column prop="resultName" label="审核结果" align="center"></el-table-column>
          <el-table-column prop="opinion" label="审核意见" align="center"></el-table-column>
          <el-table-column prop="auditTime" label="审核时间" align="center"></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
<script>
  import { activity } from '../../../../config/proxy.js'
  export default {
    data () {
      return {
        detailData: []
      }
    },
    methods: {
      searchDetail (id) {
        activity.yhqhd.dddd.detail({id: id}, (res) => {
          console.log(res)
          if (res.message === 'ok') {
            this.detailData = res.content
          } else {
            this.message('查看详情失败', 'error')
          }
        })
      },
      timeDeltSecond (d) { // 时间去秒
        if (d) {
          return d.split(' ')[0]
        }
      },
      message (text, type) { // 消息提示
        this.$message({
          showClose: true,
          message: text,
          type: type
        })
      }
    },
    created () {
      this.searchDetail(this.$store.state.tab.uid)
    }
  }
</script>
